<?
        require_once('../inc/global.php');
        require_once('Data.php');
        if(isset($_REQUEST['Submit']))
        {
                $rs = $_REQUEST;
                if(!$errors = ValidateCart($rs))
                        if(isset($_REQUEST['id']))
                        {
                                if(!$errors = SaveCart($rs))
                                        header("location: cart.php");
                        }else{
                                if(!$errors = CreateCart($rs))
                                        header("location: cart.php");
                        }
        }else{
                if(isset($_REQUEST['id']))
                        $rs = GetCartItem($_REQUEST['id']);
                else
                        $rs = NewCart();
        }
?>
<!DOCTYPE html>
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Edit Cart </title>
        <link rel="stylesheet" type="text/css" href="main.css" />
</head>
<body >
<center><h1><font color=#006784>Cart Details</font></h1></center>

        <? if(isset($errors)) { ?>
                <ul class="error">
                        <? foreach($errors as $key => $error){ ?>
                                <li><?=$key?>: <?=$error?></li>
                        <? } ?>
                </ul>
        <? } ?>
        <form method="post"><br><br><br><br><br><br><center><font color=#006784 size=3><table>
                        <tr><td>
                                <b><label>ID:</label></b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>
                                <?=$rs['id']?>
                        </td>
                        <tr><td>
                               <b> <label for="ImageLink">ImageLink:</label> </b></td><td>
                                <input  type="text" name="ImageLink" id="ImageLink"
                                                class="<? if(isset($errors['ImageLink'])){ ?>error<? } ?>"
                                                value="<?=$rs['ImageLink']?>" />
                                                <? if(isset($errors['ImageLink'])){ ?>
                                                        <span class="error"><?=$errors['ImageLink']?></span>
                                                <? } ?>
                        </td></tr>
                        <tr><td>
                                <b><label for="Category">Category:</label></b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>
                                <input  type="text" name="Category" id="Category"
                                                class="<? if(isset($errors['Category'])){ ?>error<? } ?>"
                                                value="<?=$rs['Category']?>" />
                                                <? if(isset($errors['Category'])){ ?>
                                                        <span class="error"><?=$errors['Category']?></span>
                                                <? } ?>
                        </td></tr>
                        <tr><td>
                              <b> <label for="Value">Value:</label> </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>
                                <input  type="text" name="Value" id="Value"
                                                class="<? if(isset($errors['Value'])){ ?>error<? } ?>"
                                                value="<?=$rs['Value']?>" />
                                                <? if(isset($errors['Value'])){ ?>
                                                        <span class="error"><?=$errors['Value']?></span>
                                                <? } ?>
                        </td></tr>
                         <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="submit" name="Submit" value="Submit" /></td>
                       </tr></table>
                       
        </form></font></center>
</body>
</html>


